package lzlz000.generate;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connect {

    private static Connection conn=null;
    //将加载驱动、连接数据库放入静态块中
    static{
        try {
            //加载驱动程序
            //获得数据库的连接
            String url = "jdbc:mysql://111.231.14.53:3306/scdemo?useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf-8";
            String user = "vcoin";
            String password = "QWERDF595182653";
            Class.forName("com.mysql.jdbc.Driver");//新版本的jdbc其实可以不写这句
            conn= DriverManager.getConnection(url, user, password);
        } catch ( SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection(){
        return conn;
    }
}
